import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
   {
    title: '发布时间',
    align:"center",
    dataIndex: 'createTime'
   },
   {
    title: '标题',
    align:"center",
    dataIndex: 'title'
   },
	 {
	  title: '类别',
	  align:"center",
	  dataIndex: 'pdtCategory_dictText'
	 },
   {
    title: '市场价',
    align:"center",
    sorter: true,
    dataIndex: 'deduction'
   },
   {
    title: '售价',
    align:"center",
    sorter: true,
    dataIndex: 'price'
   },
   {
    title: '商家',
    align:"center",
    dataIndex: 'shopId_dictText'
   },
   {
    title: '销量',
    align:"center",
    sorter: true,
    dataIndex: 'salesQuantity'
   },
	 {
	  title: '佣金分配方式',
	  align:"center",
	  sorter: true,
	  dataIndex: 'commissionType_dictText'
	 },
   {
    title: '已核销',
    align:"center",
    sorter: true,
    dataIndex: 'cancelledNum'
   },
   {
    title: '超时未核销',
    align:"center",
    sorter: true,
    dataIndex: 'uncancelledNum'
   },
   {
    title: '过期时间',
    align:"center",
    sorter: true,
    dataIndex: 'expirationTime'
   },
   {
    title: '租户',
    align:"center",
    dataIndex: 'tenantId'
   },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
	{
      label: "标题",
      field: 'title',
      component: 'Input',
      //colProps: {span: 6},
 	},
	{
      label: "商家",
      field: 'shopId',
      component: 'JSearchSelect',
      componentProps:{
         dict:"couple_shop,title,id"
      },
      //colProps: {span: 6},
 	},
	{
	  label: '佣金分配方式',
	  field: 'commissionType',
	  component: 'JSearchSelect',
	  componentProps:{
	     dict:"commission_type"
	  },
	},
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '标题',
    field: 'title',
    component: 'Input',
  },
  {
    label: '市场价',
    field: 'deduction',
    component: 'InputNumber',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: false},
                 { pattern: /^(([1-9][0-9]*)|([0]\.\d{0,2}|[1-9][0-9]*\.\d{0,2}))$/, message: '请输入正确的金额!'},
          ];
     },
  },
  {
    label: '售价',
    field: 'price',
    component: 'InputNumber',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: false},
                 { pattern: /^(([1-9][0-9]*)|([0]\.\d{0,2}|[1-9][0-9]*\.\d{0,2}))$/, message: '请输入正确的金额!'},
          ];
     },
  },
  {
    label: '结算价',
    field: 'settlementPrice',
    component: 'InputNumber',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: false},
                 { pattern: /^(([1-9][0-9]*)|([0]\.\d{0,2}|[1-9][0-9]*\.\d{0,2}))$/, message: '请输入正确的金额!'},
          ];
     },
  },
  {
    label: '商家',
    field: 'shopId',
    component: 'JSearchSelect',
    componentProps:{
       dict:"couple_shop,title,id,shop_category=4"
    },
  },
  {
    label: '产品类型',
    field: 'pdtCategory',
    component: 'JSearchSelect',
    componentProps:{
       dict:"pdt_category"
    },
  },
  {
    label: '佣金分配方式',
    field: 'commissionType',
    component: 'JSearchSelect',
    componentProps:{
       dict:"commission_type"
    },
  },
  {
    label: '过期时间',
    field: 'expirationTime',
    component: 'DatePicker',
    componentProps: {
       showTime: true,
       valueFormat: 'YYYY-MM-DD HH:mm:ss'
     },
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];



/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}